(function(t){"use strict";t.HSCore.components.HSCountdown={_baseConfig:{yearsElSelector:".years",monthElSelector:".month",daysElSelector:".days",hoursElSelector:".hours",minutesElSelector:".minutes",secondsElSelector:".seconds",circles:false,wrpClass:"wrpClass",textClass:"textClass",valueStrokeClass:"valueStrokeClass",maxValueStrokeClass:"maxValueStrokeClass",styleWrapper:"styleWrapper",styleText:"styleText"},pageCollection:t(),_circlesIds:[0],init:function(e,a){this.collection=e&&t(e).length?t(e):t();if(!t(e).length)return;this.config=a&&t.isPlainObject(a)?t.extend({},this._baseConfig,a):this._baseConfig;this.config.itemSelector=e;this.initCountdowns();return this.pageCollection},initCountdowns:function(){var e=this;this.collection.each((function(a,s){var i=t(s),r={endDate:i.attr("data-end-date")?!isNaN(+i.attr("data-end-date"))?new Date(+i.attr("data-end-date")):new Date(i.attr("data-end-date")):new Date,startDate:i.data("start-date")?new Date(i.data("start-date")):new Date,yearsEl:i.find(e.config["yearsElSelector"]),yearsFormat:i.data("years-format"),monthEl:i.find(e.config["monthElSelector"]),monthFormat:i.data("month-format"),daysEl:i.find(e.config["daysElSelector"]),daysFormat:i.data("days-format"),hoursEl:i.find(e.config["hoursElSelector"]),hoursFormat:i.data("hours-format"),minutesEl:i.find(e.config["minutesElSelector"]),minutesFormat:i.data("minutes-format"),secondsEl:i.find(e.config["secondsElSelector"]),secondsFormat:i.data("seconds-format")};if(e.config["circles"]&&i.data("start-date"))e._initPiesImplementation(i,r);else e._initBaseImplementation(i,r);e.pageCollection=e.pageCollection.add(i)}))},_initBaseImplementation:function(t,e){t.countdown(e.endDate,(function(t){if(e.yearsEl.length){e.yearsEl.text(t.strftime(e.yearsFormat))}if(e.monthEl.length){e.monthEl.text(t.strftime(e.monthFormat))}if(e.daysEl.length){e.daysEl.text(t.strftime(e.daysFormat))}if(e.hoursEl.length){e.hoursEl.text(t.strftime(e.hoursFormat))}if(e.minutesEl.length){e.minutesEl.text(t.strftime(e.minutesFormat))}if(e.secondsEl.length){e.secondsEl.text(t.strftime(e.secondsFormat))}}))},_initPiesImplementation:function(t,e){var a=this,s,i=24*60*60*1e3;if(e.yearsEl.length){a._preparePieItem(e.yearsEl,{maxValue:e.endDate.getFullYear()-e.startDate.getFullYear(),radius:t.data("circles-radius"),width:t.data("circles-stroke-width"),"fg-color":t.data("circles-fg-color"),"bg-color":t.data("circles-bg-color"),"additional-text":t.data("circles-additional-text"),"font-size":t.data("circles-font-size")})}if(e.monthEl.length){a._preparePieItem(e.monthEl,{maxValue:Math.round(Math.abs((e.endDate.getTime()-e.startDate.getTime())/i))/12,radius:t.data("circles-radius"),width:t.data("circles-stroke-width"),"fg-color":t.data("circles-fg-color"),"bg-color":t.data("circles-bg-color"),"additional-text":t.data("circles-additional-text"),"font-size":t.data("circles-font-size")})}if(e.daysEl.length){a._preparePieItem(e.daysEl,{maxValue:a._getDaysMaxValByFormat(e.daysFormat,e.startDate,e.endDate),radius:t.data("circles-radius"),width:t.data("circles-stroke-width"),"fg-color":t.data("circles-fg-color"),"bg-color":t.data("circles-bg-color"),"additional-text":t.data("circles-additional-text"),"font-size":t.data("circles-font-size")})}if(e.hoursEl.length){a._preparePieItem(e.hoursEl,{maxValue:60,radius:t.data("circles-radius"),width:t.data("circles-stroke-width"),"fg-color":t.data("circles-fg-color"),"bg-color":t.data("circles-bg-color"),"additional-text":t.data("circles-additional-text"),"font-size":t.data("circles-font-size")})}if(e.minutesEl.length){a._preparePieItem(e.minutesEl,{maxValue:60,radius:t.data("circles-radius"),width:t.data("circles-stroke-width"),"fg-color":t.data("circles-fg-color"),"bg-color":t.data("circles-bg-color"),"additional-text":t.data("circles-additional-text"),"font-size":t.data("circles-font-size")})}if(e.secondsEl.length){a._preparePieItem(e.secondsEl,{maxValue:60,radius:t.data("circles-radius"),width:t.data("circles-stroke-width"),"fg-color":t.data("circles-fg-color"),"bg-color":t.data("circles-bg-color"),"additional-text":t.data("circles-additional-text"),"font-size":t.data("circles-font-size")})}t.countdown(e.endDate,(function(t){if(e.yearsEl.length){e.yearsEl.data("circle").update(t.strftime(e.yearsFormat))}if(e.monthEl.length){e.monthEl.data("circle").update(t.strftime(e.monthFormat))}if(e.daysEl.length){e.daysEl.data("circle").update(t.strftime(e.daysFormat))}if(e.hoursEl.length){e.hoursEl.data("circle").update(t.strftime(e.hoursFormat))}if(e.minutesEl.length){e.minutesEl.data("circle").update(t.strftime(e.minutesFormat))}if(e.secondsEl.length){e.secondsEl.data("circle").update(t.strftime(e.secondsFormat))}}))},_preparePieItem:function(t,e){var a=this,s=a._circlesIds[a._circlesIds.length-1]+1;a._circlesIds.push(s);t.attr("id","hs-countdown-element-"+s);t.data("circle",Circles.create({id:"hs-countdown-element-"+s,radius:e["radius"]||80,value:0,maxValue:e["maxValue"]||100,width:e["width"]||10,text:function(t){return t+(e["additional-text"]||"")},colors:[e["bg-color"]||"#eeeeee",e["fg-color"]||"#72c02c"],duration:0,wrpClass:a.config["wrpClass"],textClass:a.config["textClass"],valueStrokeClass:a.config["valueStrokeClass"],maxValueStrokeClass:a.config["maxValueStrokeClass"],styleWrapper:a.config["styleWrapper"],styleText:a.config["styleText"]}));if(e["font-size"]){t.find("."+a.config["textClass"]).css("font-size",e["font-size"]+"px")}},_getDaysMaxValByFormat:function(t,e,a){var s=24*60*60*1e3;switch(t){case"%D":return Math.round(Math.abs((a.getTime()-e.getTime())/s));break;default:return 31}}}})(window.jQueryLanding||jQuery);
//# sourceMappingURL=hs.countdown.map.js